import { request } from '@umijs/max';
import { IResPage , IRes} from '.';
import {download,request1} from './download'

export interface IBusinessVisitor {
  createTime: string;
  id: number;
  telephone: string;
  wxCode: string;
  wxUnionId: string;
}

export async function apiGetBusinessVisitorLogPage(
    params: Partial<IBusinessVisitor>,
) {
  return request<IResPage<IBusinessVisitor>>('/v1/business/visitor/log/page', {
    method: 'GET',
    params,
  });
}


export async function apiGetBusinessVisitorPage(
  params: Partial<IBusinessVisitor>,
) {
  return request<IResPage<IBusinessVisitor>>('/v1/business/visitor/page', {
    method: 'GET',
    params,
  });
}

export async function updateGetBusinessVisitorPage(
    data: Partial<IBusinessVisitor>,
) {
  return request<IResPage<IBusinessVisitor>>('/v1/business/visitor/update', {
    method: 'PUT',
    data,
  });
}

export async function apiGetBusinessVisitorDelete(id: number) {
  return request<IRes<boolean>>(`/v1/business/visitor/${id}`, {
    method: 'DELETE',
  });
}

export async function apiGetBusinessVisitorExport(
    params?: any,
) {
  download(() =>
      request1("/v1/business/visitor/export", {
        method: "GET",
        params,
        responseType: "blob",
        getResponse: true,
      })
  );
}

export async function apiGetBusinessVisitorStatic() {
  return request<IResPage<IBusinessVisitor>>('/v1/business/visitor/count/statistics', {
    method: 'GET',
  });
}